package demo5;

import java.util.Arrays;

class Student implements Comparable<Student> {
    public String name;
    private int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }


    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        System.out.println("-------");
        if (this.age > o.age) {
            return 1;
        } else if (this.age == o.age) {
            return 0;
        } else {
            return -1;
        }
    }

    
}



public class Test {

    public static void main(String[] args) {


        Student student1 = new Student("zhangsan", 10);
        Student student2 = new Student("lisi", 12);

        System.out.println(student1.compareTo(student2));


    }
}
